s = input()

count_lower = 0
count_upper = 0
count_digit = 0
count_other = 0

for c in s:
    if '0' <= c <= '9' :
        count_digit += 1 
    elif 'A' <= c <= 'Z' :
        count_upper += 1 
    elif 'a' <= c <= 'z' :
        count_lower += 1 
    else:
        count_other += 1 

isCorrect = True

if len(s) < 8:
    print(1)
    isCorrect = False 

if count_other > 0:
    print(2)
    isCorrect = False
    
if not (count_upper > 0 and count_digit>0):
    print(3)
    isCorrect = False
    
if isCorrect:
    print(0)

